#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define vec vector<int>
#define y1 y_____hahahaha_____1

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 55;
const int S = 1 << 10;

int n,num[N],p[N];
char s[N];
ll ans,C[N][N];

int main(){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	scanf("%s",s + 1); n = strlen(s + 1); for(int i = 1;i <= n;i++) p[i] = s[i] - '0',num[p[i]]++;
	for(int i = 0;i <= n;i++) C[i][0] = 1;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= i;j++)
			C[i][j] = C[i-1][j] + C[i - 1][j - 1];
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < p[i];j++)
			if(num[j] >= 1){
				num[j]--; int s = n - i;ll tt = 1;
				for(int k = 0;k <= 9;k++) tt *= C[s][num[k]],s -= num[k]; ans += tt;
				num[j]++;
			}
		num[p[i]]--;
	}
	printf("%lld\n",ans);
	return 0;
}
